package com.heima;

import java.util.Scanner;

public class Homework03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //获取两个字符串
        System.out.println("请输入任意较短字符串");
        String str1 = sc.next();
        System.out.println("请输入任意较长字符串");
        String str2 = sc.next();
        //将长字符串中出现的短字符串都替换为长度为0的空字符串
        String str3 = str2.replace(str1,"");
        //将替换前后的字符串做差，得出少了多少长度，再除以短字符串的长度，即为出现的次数
        int count;
        count = (str2.length()-str3.length())/str1.length();
        System.out.println("短字符串在长字符串中出现的次数为："+count);
    }
}
